home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / misc / ConfigLib2.lha / ConfigLibrary / Test / Asm / ConfigTest.s
Encoding:
Text File  |  1996-09-07  |  1.9 KB  |  101 lines

  1. ;
  2. ; ConfigTest.s
  3. ;
  4. ; $VER: ConfigTest.s 2.0 (7.9.96)
  5. ;
  6. ; Copyright (C) 1996, Adam Dawes
  7. ;
  8. ; Refer to accompanying documentation for further details
  9. ;
  10.  
  11.  
  12. include        "config.i"
  13.  
  14.  
  15. Start:
  16.     move.l    $4,a6            ;Get ExecBase
  17.  
  18. ; Initialise -- open libraries
  19.  
  20.     lea    DosName,a1        ;Open dos.library...
  21.     move.l    #36,d0            ;Version 36
  22.     jsr    -552(a6)        ;OpenLibrary()
  23.     move.l    d0,DosBase        ;Store DosBase
  24.  
  25.     lea    ConfigName,a1        ;Open config.library...
  26.     move.l    #2,d0            ;Version 2
  27.     jsr    -552(a6)        ;OpenLibrary()
  28.     move.l    d0,ConfigBase        ;Store ConfigBase
  29.  
  30. ; Write some data to the config file
  31.  
  32.     move.l    DosBase,a6
  33.     move.l    #WritingText,d1
  34.     jsr    -948(a6)        ;Put some text telling the user we're writing to the cfg file
  35.  
  36.     move.l    ConfigBase,a6
  37.     move.l    #Filename,d0
  38.     move.l    #Section,d1
  39.     move.l    #Item,d2
  40.     move.l    #Data,d3
  41.     jsr    WriteConfig(a6)        ;Write some data to the config file
  42.  
  43.  
  44. ; Read data back to our buffer
  45.  
  46.     move.l    DosBase,a6
  47.     move.l    #ReadingText,d1
  48.     jsr    -948(a6)        ;Put some text telling the user we're reading from the cfg file
  49.  
  50.     move.l    ConfigBase,a6
  51.     move.l    #Filename,d0
  52.     move.l    #Section,d1
  53.     move.l    #Item,d2
  54.     move.l    #Buffer,d3
  55.     move.l    #255,d4
  56.     move.l    #Default,d5
  57.     jsr    ReadConfig(a6)
  58.  
  59.     move.l    DosBase,a6
  60.     move.l    #ResultsText,d1
  61.     jsr    -948(a6)        ;Show a label for our results
  62.  
  63.     move.l    #Buffer,d1
  64.     jsr    -948(a6)        ;Show what we've read back
  65.  
  66.     move.l    #CRText,d1
  67.     jsr    -948(a6)        ;Print a CR
  68.  
  69.  
  70. ;Clean up and exit
  71.  
  72.     move.l    $4,a6
  73.     move.l    ConfigBase,a1
  74.     jsr    -414(a6)        ;CloseLibrary()
  75.  
  76.     move.l    DosBase,a1
  77.     jsr    -414(a6)        ;CloseLibrary()
  78.  
  79.     rts
  80.  
  81.  
  82. DosBase:    dc.l    0
  83. DosName:    dc.b    'dos.library',0
  84. even
  85.  
  86. ConfigBase:    dc.l    0
  87. ConfigName:    dc.b    'config.library',0
  88.  
  89. Filename:    dc.b    'RAM:Test.cfg',0
  90. Section:    dc.b    'Test',0
  91. Item:        dc.b    'Name',0
  92. Data:        dc.b    'Adam Dawes',0
  93.  
  94. Buffer:        blk.b    256,0
  95. Default:    dc.b    "<unknown>",0
  96.  
  97. WritingText:    dc.b    'Writing some text to the config file...',10,0
  98. ReadingText:    dc.b    'Reading data back from file...',10,0
  99. ResultsText:    dc.b    'Name: ',0
  100. CRText:        dc.b    10,0
  101.